let http = require('./../utils/http.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    resMsg: '',
    mobile: '',
    pwd: '',
    appID: ''
  },
  onShow() {
    wx.hideHomeButton();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      appID: wx.getAccountInfoSync().miniProgram.appId
    })
  },
  login() {
    const that = this
    http.postRequest('/mini/v1/user/login', {
      mobile: that.data.mobile,
      password: that.data.pwd
    }, res => {
      if (res.code == 0) {
        wx.setStorageSync('info', {name: res.data.name, gender: res.data.gender, mobile: res.data.mobile})
        wx.setStorageSync('token', res.data.token)
        wx.setStorageSync('Identity', res.data.position_id)
        wx.setStorageSync('name', res.data.name)
        wx.reLaunch({
          url: '/pages/index?name=' + res.data.name,
        })
      }
    })
  },

  mobileInput(e) {
    this.setData({
      mobile: e.detail.value
    })
  },
  pwdInput(e) {
    this.setData({
      pwd: e.detail.value
    })
  },
  gopage() {
    wx.navigateTo({
      url: '/pages/xzozo'
    })
  },
  hide() {
    this.setData({
      resMsg: ''
    })
  }
})